<?php

class Update extends Controller {

	function index(){ }

	function v1_14($min_id = 0)
	{
		return;
		$user = $this->MUser->getFirstRow(array('id>' => $min_id, 'sort' => 'id asc'));
		if(!@$user['id']) return;
		$referals = $this->MUser->getList(array('referer_email' => $user['email']));
		$this->load->library('Operation');
		foreach($referals as $referal)
		{
			$opers = $this->MOper->getList(array('user_id' => $referal['id'], 'type' => 'buy', 'bonus' => 0, '_tmp_add_ref' => 1, '_tmp_ref_summ>' => 0));
			foreach($opers as $oper)
			{
				if(!$this->MOper->getCount(array('parent_id' => $oper['id'], 'type' => 'ref')))
				{
					$this->operation->addRefBonus($oper, $user, $referal);
				}
			}
		}
		?>
		<script language="javascript">
		
		self.location.href = '<?=base_url()?>update/v1_14/<?=$user['id']?>';
		
		</script>
		<?
	}

	function v1_15()
	{
		mysql_query('ALTER TABLE `schet_fix` ADD `last_platezh_id` INT UNSIGNED NOT NULL');
		echo mysql_error();
		mysql_query('insert into exchange (`valuta`, `date`, `kurs`, `nominal`) values ("THB", "2011-01-01", "1", "1")');
		echo mysql_error();

		$sql = "UPDATE schet_fix sf SET last_platezh_id = (SELECT id FROM platezh WHERE schet_id = sf.schet_id AND time_add < sf.time_add ORDER BY id DESC LIMIT 1)";
		mysql_query($sql);
		echo mysql_error();

		mysql_query('ALTER TABLE `user` DROP `update_password` ');
		echo mysql_error();

		mysql_query('ALTER TABLE `user` DROP `referer_id` ');
		echo mysql_error();

		mysql_query("ALTER TABLE `user` ADD `can_oper` TINYINT( 1 ) UNSIGNED DEFAULT '0' NOT NULL");
		echo mysql_error();

		mysql_query("ALTER TABLE `user` ADD `can_oper_delete` TINYINT( 1 ) UNSIGNED DEFAULT '0' NOT NULL");
		echo mysql_error();

	}



	
}

